<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/core.js"></script>
<script>
   var getUserInfo = function (userId,callback) {
       $.ajax('http://www.baidu.com?'+userId,function (data) {
           callback(data)
       })
   }
   getUserInfo(1234,function (data) {
       alert(data.userName)
   })
</script>
</body>
</html>